package com.naiterui.ehp.bs.cms.common.constants;

/**
 * ocr状态码枚举
 *
 * @author yangfuya
 * @version 1.0
 * @date 2021/4/22 13:53
 **/
public enum OcrEnum {
    /**
     * 公共错误码
     */
    AUTHFAILURE_SIGNATUREFAILURE("AuthFailure.SignatureFailure", "签名错误"),
    /**
     * 身份证识别相关
     */
    FAILEDOPERATION_EMPTYIMAGEERROR("FailedOperation.EmptyImageError", "图片内容为空"),
    FAILEDOPERATION_IDCARDINFOILLEGAL("FailedOperation.IdCardInfoIllegal", "身份证信息不合法（身份证号、姓名字段校验非法等）"),
    FAILEDOPERATION_IMAGEBLUR("FailedOperation.ImageBlur", "图片模糊"),
    FAILEDOPERATION_IMAGENOIDCARD("FailedOperation.ImageNoIdCard", "图片中未检测到身份证"),
    FAILEDOPERATION_IMAGESIZETOOLARGE("FailedOperation.ImageSizeTooLarge", "图片尺寸过大，请参考输出参数中关于图片大小限制的说明"),
    FAILEDOPERATION_MULTICARDERROR("FailedOperation.MultiCardError", "OCR识别失败"),
    FAILEDOPERATION_OCRFAILED("FailedOperation.OcrFailed", "图片内容为空"),
    FAILEDOPERATION_TOOLARGEFILEERROR("FailedOperation.TooLargeFileError", "文件内容太大"),
    ;
    private String errCode;
    private String msg;

    OcrEnum(String errCode, String msg) {
        this.errCode = errCode;
        this.msg = msg;
    }

    public String getErrCode() {
        return errCode;
    }

    public String getMsg() {
        return msg;
    }

    /**
     * 根据传进来的errCode动态返回msg
     *
     * @param errCode
     * @return
     */
    public static String getOcrEnumMsg(String errCode) {
        OcrEnum[] ocrEnums = values();
        for (OcrEnum ocrEnum : ocrEnums) {
            if (ocrEnum.getErrCode().equals(errCode)) {
                return ocrEnum.getMsg();
            }
        }
        return null;
    }
}
